fix(android): Drop inflated app start for background-spawned processes on API 35+ - #5841
Open
alwx wants to merge 4 commits into
Open
fix(android): Drop inflated app start for background-spawned processes on API 35+#5841alwx wants to merge 4 commits into
alwx wants to merge 4 commits into
Conversation
…s on API 35+ When the OS spawns the process for background work (FCM push, job, service, broadcast, etc.) and the user opens the app later, the app start stayed anchored at background process creation, inflating the reported cold start by the whole idle gap. On API 35+ we now use ApplicationStartInfo.getReason() to detect background process starts and mark them as not launched in foreground, so the first created activity re-classifies them as a warm start anchored at activity creation.
📲 Install BuildsAndroid
|
5 tasks
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 05aa61d | 326.06 ms | 385.46 ms | 59.40 ms |
| bb0ff41 | 315.84 ms | 350.76 ms | 34.92 ms |
| 806307f | 357.85 ms | 424.64 ms | 66.79 ms |
| d501a7e | 307.33 ms | 341.94 ms | 34.61 ms |
| 0ee65e9 | 321.06 ms | 361.24 ms | 40.18 ms |
| ed33deb | 334.19 ms | 362.30 ms | 28.11 ms |
| 9fbb112 | 401.87 ms | 515.87 ms | 114.00 ms |
| b8bd880 | 314.56 ms | 336.50 ms | 21.94 ms |
| 5b1a06b | 315.40 ms | 353.33 ms | 37.94 ms |
| 6edfca2 | 316.43 ms | 398.90 ms | 82.46 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 05aa61d | 0 B | 0 B | 0 B |
| bb0ff41 | 0 B | 0 B | 0 B |
| 806307f | 1.58 MiB | 2.10 MiB | 533.42 KiB |
| d501a7e | 0 B | 0 B | 0 B |
| 0ee65e9 | 0 B | 0 B | 0 B |
| ed33deb | 1.58 MiB | 2.13 MiB | 559.52 KiB |
| 9fbb112 | 1.58 MiB | 2.11 MiB | 539.18 KiB |
| b8bd880 | 1.58 MiB | 2.29 MiB | 722.92 KiB |
| 5b1a06b | 0 B | 0 B | 0 B |
| 6edfca2 | 1.58 MiB | 2.13 MiB | 559.07 KiB |
alwx
marked this pull request as ready for review
July 28, 2026 08:01
alwx
requested review from
0xadam-brown,
adinauer,
markushi,
romtsn and
runningcode
as code owners
July 28, 2026 08:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
On API 35+, use
ApplicationStartInfo.getReason()to detect processes the OS spawned for background work (FCM push, job, service, broadcast, alarm, backup, boot_complete, content_provider) and mark them as not launched in foreground. The first created activity then re-classifies the launch as a warm start re-anchored at activity creation, instead of reporting the whole background idle gap as an inflated cold start.Reported by a user of RN SDK: getsentry/sentry-react-native#6382
💡 Motivation and Context
When a process is spawned in the background (e.g. by an FCM push) and the user opens the app seconds later,
appLaunchedInForegroundwas only evaluated lazily and the app start span stayed anchored at background process creation. On API 35+ the main-looper idle check that would otherwise mark the launch as headless is skipped once the start type is resolved fromApplicationStartInfo, so the inflated cold start (idle gap up to ~1 min) leaked through intoapp_start_cold.Fixes getsentry/sentry-react-native#6382
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Follow-up: API < 35 has no reliable process start reason, so a narrow race in the main-looper idle check remains there; not addressed here.